package com.example.demo.use_demo.a_gitlab4j;

import org.gitlab4j.api.Constants;
import org.gitlab4j.api.GitLabApi;
import org.gitlab4j.api.GitLabApiException;
import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.models.RepositoryArchiveParams;
import org.gitlab4j.api.models.TreeItem;

import java.io.InputStream;
import java.util.List;

/**
 * @author farben
 */
public class Gitlab4jUtil {

    /**
     * gitlab操作
     */
    private void gitlab4j() throws GitLabApiException {
        GitLabApi gitLabApi = new GitLabApi("http://172.16.10.31","x9sF2-zSx4euDE2EDk_n");
        gitLabApi.setRequestTimeout(2000,5000);

        List<TreeItem> repositoryTree = gitLabApi.getRepositoryApi().getTree("664");
        List<TreeItem> repositoryTree2 = gitLabApi.getRepositoryApi().getTree("664","国信证券薪酬系统","master",true);
        List<TreeItem> repositoryTree3 = gitLabApi.getRepositoryApi().getTree("664","国信证券薪酬系统/测试子文件夹","master",true);
        List<Project> projects = gitLabApi.getProjectApi().getProjects();
        InputStream rawFile = gitLabApi.getRepositoryFileApi().getRawFile("664", "master", "国信证券薪酬系统/Spring源码分析.pdf");
        InputStream inputStream = gitLabApi.getRepositoryApi().getRepositoryArchive(664, new RepositoryArchiveParams(), Constants.ArchiveFormat.ZIP);
    }

}
